Tree object (Multivariate Analysis Toolbox for MatlabŪ)

written by: Liran Carmel

Last modified: 14:4, Sun 12-Sep-2010

General Description
A tree is a directed graph (digraph) for which each node (except for the root) has exactly one parent. There is no limit to the number of descendants of each node. This objects inherits from the parent object digraph.

Navigate to:     General Description     Class Structure     Class Construction     Class Functions

Class Structure
Each field can be accessed by the dot (.) operation, or by the GET function. The GET function can work on multiple instances simultaneously. Most fields, except for those that are Dependent, can be modified using the dot (.) operation, or by the SET function.
    Field Description Type Default Dedicated Get/Set Function  
    parent parent of each node double vector []    
    thd Inherited from digraph. target-height-differences matrix double matrix []    
    name Inherited from graph. name of object, should be short and used as identifier. This field will never be empty. string 'unnamed'    
    description Inherited from graph. verbal description of the class content. string ''    
    source Inherited from graph. verbal description of the source of information. string ''    
    type Inherited from graph. type of graph. string 'general graph'    
    node_name Inherited from graph. names of all nodes. cell array of strings {} nodenames  
    node_mass Inherited from graph. mass of each node. double vector []    
    node_cfield Inherited from graph. user-specific node customized fields. cell array of values {}    
    node_cfield_name Inherited from graph. names of node customized fields. cell array of strings {}    
    weights Inherited from graph. symmetric sparse weight matrix. double matrix []    
  Dependent no_nodes Inherited from graph. number of nodes in the graph. integer scalar 0 nonodes  
  Dependent no_node_cfields Inherited from graph. number of customized fields. integer scalar 0    
  Dependent no_edges Inherited from graph. number of edges in the graph. integer vector 0 noedges  

Class Construction
Empty instance (scalar)
an empty tree instance, with all fields initialized to their default values.
syntax: tr = tree;
Empty instance (matrix)
an array of empty tree instances.
syntax: tr = tree(size,'size');
Copy constructor
one tree instance is copied into another.
syntax: tr_destination = tree(tr_origin);
Construction by field names
an instance is formed by directly providing field values. Any field which is not dependent is permitted.
syntax: tr = tree(field_name, field_value, ...);

List of Functions

Computations:

balance
computes the balance vector. Source: digraph.
dag2code
finds the DAG-code of a DAG. Source: digraph.
laplacian
computes the Laplacian of a graph. Source: graph.
vstruct
finds nodes that are center of a V-structure. Source: digraph.

Customized fields manipulations:

alloccfield
allocates a new customized field to a graph. Source: graph.
cfieldexist
finds whether a customized field exists in a graph. Source: graph.
cfieldnames
lists the customized fields in a GRAPH object. Source: graph.
getcfield
retrieves a customized field from a graph. Source: graph.
setcfield
sets values for a customized field of GRAPHs. Source: graph.

Display:

show
displays class content. Source: graph.

I/O functions:

dump
writes a DIGRAPH to disk. Source: digraph.

Information extraction:

ancestors
finds the sequence of ancestors of a specifed node.
descendants
finds all descandants of a specifed node.
iodegree
computes the in and out degrees of a digraph. Source: digraph.
iscyclic
finds whether a DIGRAPH is cyclic or not. Source: digraph.
lca
finds the last common ancestor of a list of nodes.
leaves
finds these nodes that are leaves.
leavesunder
lists the leaves that are descendants of a particular node.
nodeid
finds the IDs of a list of nodes. Source: graph.
parents
finds the parents of specific nodes. Source: digraph.
root
finds the root of the tree.

Maintenance:

verify
computes missing.

SET/GET functions:

get
get method
nodenames
retrieves the name of the nodes in the graph. Source: graph.
noedges
retrieves the number of edges in GRAPH objects. Source: graph.
nonodes
retrieves the number of nodes in GRAPH objects. Source: graph.
set
set method

Transformations:

order
orders the nodes in a tree.
prunesubtree
prunes a subtree.
subtree
isolates the subtree branching from a certain node.
swap
replaces the indices of two nodes.
updatesubtree
substitutes the fields of a subtree in the father tree.

Visualization:

eigenproj
computes the eigenprojection of a graph. Source: graph.
view
plots a DIGRAPH Source: digraph.